//
//  BorrowApplyTableViewCell.m
//  51易借
//
//  Created by apple on 2017/9/19.
//  Copyright © 2017年 张睿. All rights reserved.
//

#import "BorrowApplyTableViewCell.h"

@implementation BorrowApplyTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    if(SCREEN_WIDTH>=375)
    {
        self.leftContraint.constant = 259;
        self.centerContraint.constant = 0;
    }else
    {
        self.leftContraint.constant = 19;
        self.centerContraint.constant = 20;
    }
    [self layoutIfNeeded];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)feiTask:(id)sender {
    if(self.feiBlock)
    {
        self.feiBlock(self.model);
    }
}
- (IBAction)agreeTask:(UIButton *)sender {
    sender.selected = !sender.selected;
}
- (IBAction)agreementTask:(UIButton *)sender {
    if(self.agreementBlock)
    {
        self.agreementBlock(sender.tag);
    }
}
- (IBAction)suretask:(id)sender {
    if(self.sureBlock)
    {
        self.sureBlock(self.model);
    }
}

- (IBAction)didHelpButton:(id)sender {
    
//    NSLog(@"haha");
//    NSLog(@"Thread:%@",[NSThread currentThread]);
    [[NSNotificationCenter defaultCenter] postNotificationName:@"toShowSeviceCost" object:nil];
}

//借款协议
- (IBAction)didBorrowButton:(id)sender {
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"pushToWebVCSix" object:nil];
}

//平台服务协议
- (IBAction)didSeviceButton:(id)sender {
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"pushToWebVCSeven" object:nil];
}

//授权扣款委托书
- (IBAction)payMoneyButton:(id)sender {
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"pushToWebVCEight" object:nil];
}


-(void)setModel:(BorrowApplyModel *)model
{
    _model = model;
    if(model){
    self.amountLabel.text = [NSString stringWithFormat:@"%.2f元",[model.borrowAmount floatValue]];
    self.timeLabel.text = [NSString stringWithFormat:@"%d天",[model.borrowDays intValue]];
    self.lxLabel.text = [NSString stringWithFormat:@"%.2f元",[model.basicInterest floatValue]];
    self.feiLabel.text = [NSString stringWithFormat:@"%.2f元",[model.totalServiceFee floatValue]];
    self.getAmountLabel.text = [NSString stringWithFormat:@"%.2f元",[model.actualIncome floatValue]];
    self.yhLabel.text = [NSString stringWithFormat:@"%.2f元",[model.borrowAmount floatValue]];

    self.dateLabel.text = [Lahelper formattedTimeFromTimeInterval:[model.overdueTime longLongValue]];
    }
}

-(void)setMember:(MemberInfoModel *)member
{
    _member = member;
    if(member){
    NSString*number = member.bankCard.length>=4?[member.bankCard substringFromIndex:member.bankCard.length-4]:member.bankCard;

    self.bankLabel.text = [NSString stringWithFormat:@"%@(尾号%@)",member.bank,number];
    }
}


@end
